#ifndef KEYBOARDMAIN_H
#define KEYBOARDMAIN_H

#include <QWidget>
#include <QFrame>
#include <QLabel>
#include <QVBoxLayout>
#include <QSlider>
#include <QLineEdit>
#include <QGSettings/QGSettings>
#include <QPushButton>
#include <QProcess>
#include <QDebug>
#include <QtDBus/QDBusInterface>
#include "shell/interface.h"

#include "widgets/Label/titlelabel.h"
#include "widgets/Uslider/uslider.h"
#include "widgets/SettingWidget/lineeditwidget.h"
#include "widgets/SettingWidget/switchwidget.h"
#include "widgets/SettingWidget/sliderwidget.h"
#include "widgets/SettingWidget/settinggroup.h"

#include "interface/common.h"

#include <kswitchbutton.h>
using namespace kdk;

const QByteArray kKeyboardSchamas = "org.ukui.peripherals-keyboard";
const QString kKeyRepeatKey = "repeat";
const QString kDelayKey = "delay";
const QString kSpeedKey = "rate";

const QByteArray kKeyboardOsdSchemas = "org.ukui.control-center.osd";
const QString kKeyTipsKey = "show-lock-tip";

class KeyboardMain : public QWidget, CommonInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
    Q_INTERFACES(CommonInterface)
public:
    KeyboardMain();
    ~KeyboardMain() Q_DECL_OVERRIDE;

    QString plugini18nName() Q_DECL_OVERRIDE;
    int pluginTypes() Q_DECL_OVERRIDE;
    QWidget *pluginUi() Q_DECL_OVERRIDE;
    const QString name() const Q_DECL_OVERRIDE;
    bool isShowOnHomePage() const Q_DECL_OVERRIDE;
    QIcon icon() const Q_DECL_OVERRIDE;
    bool isEnable() const Q_DECL_OVERRIDE;

private:
    QString pluginName;
    int pluginType;
    QWidget *pluginWidget;

    bool mFirstLoad;

private:
    SwitchWidget *mKeyRepeatFrame;        //按键重复
    SliderWidget *mDelayFrame;            //延迟
    SliderWidget *mSpeedFrame;            //速度
    LineEditWidget *mInputTestFrame;        //输入测试
    SwitchWidget *mKeyTipsFrame;          //按键提示

    SettingGroup *mKeyboardFrame;

    TitleLabel *mKeyboardSetTitleLabel;

    QPushButton *mInputMethodSetBtn;    //输入法设置

    QVBoxLayout *mVlayout;

    QGSettings *mKeyboardGsettings;
    QGSettings *mKeyboardOsdGsetting;

private:
    void initUI(QWidget *widget);
    void setKeyRepeatFrame();
    void setDelayFrame();
    void setSpeedFrame();
    void setInputTestFrame();
    void setKeyTipsFrame();
    void initConnection();
    void initKeyboardStatus();
    void setKeyboardVisible(bool checked);
    void gsettingConnectUi();

    void keyRepeatSlot(bool checked);
    void keyDelaySlot(int value);
    void keySpeedSlot(int value);
    void inputTestSlot();
    void keyTipsSlot(bool checked);
    void inputMethodSetSlot();

    bool eventFilter(QObject *watched, QEvent *event);

};
#endif // KEYBOARDMAIN_H
